<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<div class="entry-edit">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Relays') ?></h4>
    </div>
    <fieldset id="grop_fields">
    <?php if(0&& $this->getProductId()): ?>
        <ul class="messages">
            <li class="notice-msg">
                <ul>
                    <li><?php echo Mage::helper('catalog')->__("Relays") ?></li>
                </ul>
            </li>
        </ul>
    <?php endif; ?>
		<?php foreach ($this->getRelayCollection() as $_relay): ?>
		<div>
        <div class="relay-name">
            <input name="product[relay_ids][]" value="<?php echo $_relay->getId() ?>" <?php if ($this->isReadonly()):?> disabled="disabled"<?php endif;?> class="checkbox relay-checkbox" id="product_relay_<?php echo $_relay->getId() ?>" type="checkbox"<?php if($this->hasRelay($_relay->getId())): ?> checked="checked"<?php endif; ?> />
            <big><strong><label for="product_relay_<?php echo $_relay->getId() ?>"><?php echo $_relay->getTitle() . ' - '. $_relay->getDesc()?></label></strong></big>
        </div>
		</div>
    <?php endforeach; ?>		
    
    </fieldset>
</div>
<script type="text/javascript">
//<![CDATA[
    var productRelayCheckboxes = $$('.relay-checkbox');

    for(var i=0;i<productRelayCheckboxes.length;i++){
        Event.observe(productRelayCheckboxes[i], 'click', toggleStoreFromChoosers);
    }

    function toggleStoreFromChoosers(event){
        var element = Event.element(event);      
				var relays = '0' ;
				for(var i=0;i<productRelayCheckboxes.length;i++){
					if (productRelayCheckboxes[i].checked) {
						relays += ','+ productRelayCheckboxes[i].value;
					}
				}
				if($('relay_ids'))
	        $('relay_ids').value=  relays   ;
					
				/*
				var relay_ids = document.getElementsByName('product[relay_ids]');
				for(var i=0;i<relay_ids.length;i++){
					relay_ids[i].value = relays   ;
				}
				*/
				
    }
//]]>
</script>
